package GUI;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import java.awt.event.ActionListener;
import javax.swing.JSeparator;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


/**
 *
 * @author David Ponce
 */

public class MenueBar {

    final Main td;

public JMenuBar getMenueLeiste() {


    return menueLeiste;
    }

    //Menüleiste
    JMenuBar menueLeiste;

    //Menüleiste Elemente
    JMenu datei = new JMenu("Datei");

    //Datei
    JMenuItem editor = new JMenuItem("Editor");
    JMenuItem report = new JMenuItem("Report");
    JMenuItem beenden = new JMenuItem("Programm beenden");

    public MenueBar(final Main td){

        this.td = td;

        menueLeiste = new JMenuBar();

        //Menüelemente erzeugen

        //Menüelemente hinzufügen
        menueLeiste.add(datei);


        datei.add(editor);
        datei.add(report);
        datei.add(new JSeparator());
        datei.add(beenden);


    beenden.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e){

                System.exit(0);
            }
        });
    editor.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e){
                
//                td.leftp.add(td.scrollTree);


//                ((CardLayout) td.rightp.getLayout()).show(td.rightp, "One");
//                td.setVisible(true);

//            ((CardLayout) rightp.getLayout()).show(rightp, "One");

//                JMenuItem menuItem = (JMenuItem) e.getSource();
//                JPopupMenu popupMenu = (JPopupMenu) menuItem.getParent();
//                Component invoker = popupMenu.getInvoker(); //this is the JMenu (in my code)
//                JComponent invokerAsJComponent = (JComponent) invoker;
//                Container topLevel = invokerAsJComponent.getTopLevelAncestor();
//                topLevel.setVisible(false);
//                SplitPaneNow.SplitPaneNow();
            }
        });
    report.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e){
//
//                td.leftp.add(td.scrollTree2);
            }
        });
}
}